import Quill from 'quill';
import Pdf from 'src/app/shared/pdf';

const BlockEmbed = Quill.import('blots/block/embed');

class PdfBlot extends BlockEmbed {
  static blotName = 'pdf';
  static tagName = 'iframe';

  static create(value): any {
    const node = super.create(value);
    const { id = PdfBlot.blotName, width = 800, height = 600 } = value;

    node.setAttribute('id', id);
    if (width !== undefined) {
      node.setAttribute('width', width);
    }
    if (height !== undefined) {
      node.setAttribute('height', height);
    }

    const pdf = new Pdf(node);
    return node;
  }
}

export default PdfBlot;
